package cn.rocksolid.sport.common.error;

import cn.rocksolid.sport.common.Constant.ECR;

/**
 * 00000 - 19999 System Errors<br>
 * 20000 - 29999 Activity Errors<br>
 * 30000 - 39999 Agency Errors<br>
 * 40000 - 49999 Assist Errors<br>
 * 50000 - 59999 Member Errors<br>
 * 60000 - 69999 Order Errors<br>
 * 70000 - 79999 Security Errors<br>
 *
 * @author Axl Zhao
 */
public enum RSE {
  //****************************/
  //** 0 - 19999 System Errors */
  //****************************/
  /** 00000 - 00099 Native unknown errors as below */
  UNKNOWN(ECR.SYS, "Unknown error"),
  UNSUPPORTED_OPERATION(ECR.SYS + 1, "The operation is unsupported"),
  UNSUPPORTED_TYPE(ECR.SYS + 2, "The type is unsupported"),
  FORBIDDEN(ECR.SYS + 3, "Access has been denied"),
  UNAUTHORIZED(ECR.SYS + 4, "Accessing did not authorized"),
  /** 00100 - 00499 Context errors as below */
  INVALID_RSCTX(ECR.SYS + 100, "Invalid RockSolid context"),
  INVALID_ACCESS_ID(ECR.SYS + 101, "Invalid access ID of context"),
  INVALID_ACCESS_TYPE(ECR.SYS + 102, "Invalid access type of context"),
  INVALID_TOKEN(ECR.SYS + 103, "Invalid token of context"),
  INVALID_CLIENT_IP(ECR.SYS + 104, "Invalid client IP of context"),
  INVALID_AGENCY_ID(ECR.SYS + 105, "Invalid agency ID of context"),
  INVALID_APPID(ECR.SYS + 106, "Invalid agency app ID of context"),
  INVALID_APPTYPE(ECR.SYS + 107, "Invalid agency app type of context"),
  /** 00500 - 19999 System level business errors as below */
  INVALID_HTTP_REQ(ECR.SYS + 500, "Invalid HTTP request"),
  INVALID_PAYLOAD(ECR.SYS + 501, "Invalid payload data"),
  INVAILD_PAGE(ECR.SYS + 502, "Invalid pagination object"),
  INVALID_EMAIL(ECR.SYS + 503, "Invalid email"),
  INVALID_MOBILE(ECR.SYS + 504, "Invalid mobile"),
  INVALID_IDCARD(ECR.SYS + 505, "Invalid IdCard"),
  INVALID_GUID32(ECR.SYS + 506, "Invalid 32bits GUID"),
  INVALID_CHECKSUM_ALGORITHM(ECR.SYS + 507, "Invalid checksum data or checksum algorithm"),
  XML_TRANSFORM_ERR(ECR.SYS + 508, "Error occurred when transform XML content"),
  FTL_PROCESS_ERR(ECR.SYS + 509, "Freemarker template processing error"),
  INVALID_DT_RANGE(ECR.SYS + 511, "Invalid time/date/datetime range"),
  HTTP_COMM_ERR(ECR.SYS + 512, "Http communication error"),
  INVALID_GENDER(ECR.SYS + 513, "Invalid gender"),
  INVALID_PWD(ECR.SYS + 514, "Invalid password"),
  INVALID_NAME(ECR.SYS + 515, "Invalid name"),
  INVALID_IMAGE(ECR.SYS + 516, "Invalid image url"),
  PWD_MISMATCH(ECR.SYS + 517, "Password mismatch"),
  INVALID_ID(ECR.SYS + 518, "Invalid identity"),
  //**********************************/
  //** 20000 - 29999 Activity Errors */
  //**********************************/
  /** 20200 - 20299 Activity type service related */
  DUP_ATN(ECR.ACTIVITY + 206, "The activity type name already exist"),
  /** 20600 - 20699 Material type service related */
  DUP_AMN(ECR.ACTIVITY + 604, "The material type name already exist"),
  DUP_ASIN(ECR.ACTIVITY + 704, "The score indicator name already exist"),
  /** 21000 - 21099 Attendee role related */
  DUP_AARN(ECR.ACTIVITY + 1003, "The attendee role name already exist"),
  /** 21400 - 21499 training lesson related */
  INVALID_ATLN(ECR.ACTIVITY + 1401, "Invalid trainning lesson name"),
  ATE_OVER_VOL(ECR.ACTIVITY + 1503, "Training Event capacity is full"),
  //********************************/
  //** 30000 - 39999 Agency Errors */
  //********************************/
  /** 30000 - 30099 Agency service related */
  INVALID_AGN(ECR.AGENCY + 1, "Invalid agency name"),
  INVALID_AGLOGO(ECR.AGENCY + 2, "Invalid logo of agency"),
  DUP_AGN(ECR.AGENCY + 3, "The agency name or agency ID already exist"),
  INVALID_AGD(ECR.AGENCY + 4, "Invalid agency description"),
  INIT_AGE(ECR.AGENCY + 5, "Create agency error"),
  AG_NOTFOUND(ECR.AGENCY + 6, "The agency not found"),
  /** 30100 - 30200 Agency station */
  INVALID_AGSN(ECR.AGENCY + 100, "Invalid agency station name"),
  INVALID_AGSD(ECR.AGENCY + 101, "Invalid agency station description"),
  /** 30200 - 30300 agency contact */
  INVALID_AGCP(ECR.AGENCY + 200, "Invalid agency contact photo"),
  /** 30300 - 30399 Agency application platform service related */
  INVALID_AGAPPN(ECR.AGENCY + 300, "Invalid name of agency application"),
  INVALID_AGAPP_OID(ECR.AGENCY + 301, "Invalid origin app ID of agency application"),
  INVALID_AGAPP_TYPE(ECR.AGENCY + 302, "Invalid type of agency application"),
  INVALID_AGAPP_ID(ECR.AGENCY + 303, "Invalid ID of agency application"),
  /** 30400 - 30499 Agency SMTP setting */
  INVALID_AGSMTPS_UNAME(ECR.AGENCY + 400, "Invalid username of agency smtp setting"),
  INVALID_AGSMTPS_PWD(ECR.AGENCY + 401, "Invalid password of agency smtp setting"),
  INVALID_AGSMTPS_HOST(ECR.AGENCY + 402, "Invalid host/hostname of agency smtp setting"),
  INVALID_AGSMTPS_PORT(ECR.AGENCY + 403, "Invalid port number of agency smtp setting"),
  INVALID_AGSMTPS_SN(ECR.AGENCY + 404, "Invalid sender of agency smtp setting"),
  /** 30500 - 30599 Agency SMTP template */
  INVALID_AGSMTPT_NAME(ECR.AGENCY + 500, "Invalid name of agency smtp template"),
  INVALID_AGSMTPT_DESC(ECR.AGENCY + 501, "Invalid description of agency smtp template"),
  INVALID_AGSMTPT_TL(ECR.AGENCY + 502, "Invalid content of agency smtp template"),
  INVALID_AGSMTPT_SID(ECR.AGENCY + 503, "Invalid setting ID of agency smtp template"),
  //********************************/
  //** 40000 - 49999 Assist Errors */
  //********************************/
  /** 40000 - 40099 IdCard validation service related */
  MISS_IVP_DC(ECR.ASSIST, "Missing default configuration of IdCard validation provider"),
  MISS_IVP(ECR.ASSIST + 1, "IdCard validation provider missing"),
  INVALID_IVP_CONF(ECR.ASSIST + 2, "Invalid configuration of IdCard validation provider"),
  /** 40100 - 40199 OSS service related */
  INVALID_OSSID(ECR.ASSIST + 100, "Invalid OSS ID"),
  INVALID_OSSUTYPE(ECR.ASSIST + 101, "Invalid OSS upload type"),
  OSSP_INIT_FAIL(ECR.ASSIST + 102, "Initial OSS provider failure"),
  MISS_OSSP_DC(ECR.ASSIST + 103, "Missing default configuration of OSS provider"),
  INVALID_OSSP_CONF(ECR.ASSIST + 104, "Invalid configuration of OSS provider"),
  /** 40200 - 40299 SMS service related */
  INVALID_SMS_PARAMS(ECR.ASSIST + 200, "Invalid SMS parameters"),
  INVALID_SMS_MOBILES(ECR.ASSIST + 201, "Invalid SMS mobiles, should be between 0 and 100"),
  MISS_SMSP_DC(ECR.ASSIST + 202, "Missing default configuration of SMS provider"),
  INVALID_SMSP_CONF(ECR.ASSIST + 203, "Invalid configuration of SMS provider"),
  MISS_SMSP(ECR.ASSIST + 204, "SMS provider missing"),
  /** 40300 - 40399 EmailSetting/Threshold */
  INVALID_ES_CONF(ECR.ASSIST + 300, "Invalid email service configuration"),
  INVALID_EMAILTEMP(ECR.ASSIST + 301, "Invalid email template"),
  /** 40400 - 40499 TASK */
  RS_TASK_FAIL(ECR.ASSIST + 400, "RockSolid task execution failure"),
  //********************************/
  //** 50000 - 59999 Member Errors */
  //********************************/
  /** 50000 - 50099 Member service related */
  INVALID_MID(ECR.MEMBER + 1, "Invalid member ID"),
  INVALID_MNN(ECR.MEMBER + 2, "Invalid member nickname"),
  M_NOTFOUND(ECR.MEMBER + 10, "Member not found"),
  DUP_MLOGID(ECR.MEMBER + 12, "Member login id duplicated, such as Email/Mobile/IdCard"),
  /** 50100 - 50199 Member app bind service related */
  INVALID_MAB_PAID(ECR.MEMBER + 100, "Invalid pre-access ID of agency app side"),
  INVALID_MAB_AUID(ECR.MEMBER + 101, "Invalid app unique ID of agency app side"),
  AGAPP_LOG_FAIL(ECR.MEMBER + 102, "Agency app login failure"),
  MAB_EXIST(ECR.MEMBER + 103, "The member app bind relationship already exist"),
  /** 50300 - 50399 Membership */
  INVALID_MSID(ECR.MEMBER + 300, "Invalid membership ID"),
  INVALID_MSN(ECR.MEMBER + 301, "Invalid membership name"),
  INVALID_MSP(ECR.MEMBER + 302, "Invalid membership price"),
  /** 50400 - 50499 Account type related */
  INVALID_MSATID(ECR.MEMBER + 400, "Invalid account type ID"),
  INVALID_MSATN(ECR.MEMBER + 401, "Invalid account type name"),
  INVALID_MSATD(ECR.MEMBER + 402, "Invalid account type description"),
  DUP_MSATN(ECR.MEMBER + 403, "Account type name already exist"),
  /** 50500 - 50599 Membership account related */
  INVALID_MSAID(ECR.MEMBER + 500, "Invalid membership account ID"),
  INVALID_MSALM(ECR.MEMBER + 501,
          "Invalid count of leave months for membership account, which should be between 1 and 12"),
  MSA_TX_TYPE_ERR(ECR.MEMBER + 502, "Membership account transaction type error"),
  MSA_TX_TIMEOUT(ECR.MEMBER + 503, "Membership account transaction timeout"),
  MSA_TX_ERR(ECR.MEMBER + 504, "Membership account transaction error"),
  MSA_TX_MSA_EXIST(ECR.MEMBER + 505, "Membership account already exist"),
  MSA_TX_AT_MISMATCH(ECR.MEMBER + 506, "Membership account type mismatch"),
  MSA_TX_MISS_MS(ECR.MEMBER + 507, "Membership product does not exist"),
  MSA_TX_LT_NE(ECR.MEMBER + 508, "Count of available leave of membership account is not enough"),
  MSA_TX_TT_NE(ECR.MEMBER + 509, "Count of available transfer of membership account is not enough"),
  MSA_TX_ST_ERR(ECR.MEMBER + 510, "Membership account transaction status error"),
  /** 50600 - 50699 Group related */
  INVALID_GROUP_MEMBERS(ECR.MEMBER + 600, "Group members should not be empty"),
  EXISTED_GROUP_MEMBER(ECR.MEMBER + 601, "Group member already existed"),
  //*******************************/
  //** 60000 - 69999 Order Errors */
  //*******************************/
  /** 60000 - 60199 Order service related */
  INVALID_OID(ECR.ORDER, "Invalid order ID"),
  INVALID_OOL(ECR.ORDER + 1, "Invalid order line, which related purchase missing or unavailable"),
  OTX_TYPE_ERR(ECR.ORDER + 2, "Order transaction type error"),
  OTX_TIMEOUT(ECR.ORDER + 3, "Perform order transaction has been timeout"),
  OTX_ERR(ECR.ORDER + 4, "The unkonw error occurred when perform order transaction"),
  OTX_ST_ERR(ECR.ORDER + 5, "Order transaction status error"),
  OTX_PAOTDB(ECR.ORDER + 6, "The payment amount does over than debit balance of the order"),
  /** 60200 - 60399 Payment service related */
  INVALID_PAYID(ECR.ORDER + 200, "Invalid payment ID"),
  INVALID_PAYAMT(ECR.ORDER + 201, "Payment amount cannot be empty"),
  INVALID_PAYCURR(ECR.ORDER + 202, "Invalid payment currency"),
  INVALID_PAYOIDS(ECR.ORDER + 203, "Invalid payment orders, required at least 1 order"),
  PTX_TYPE_ERR(ECR.ORDER + 204, "Payment transaction type error"),
  PTX_ST_ERR(ECR.ORDER + 205, "Payment transaction status error"),
  PTX_TIMEOUT(ECR.ORDER + 206, "Perform payment transaction has been timeout"),
  PTX_ERROR(ECR.ORDER + 207, "The error occurred when perform payment transaction"),
  PG_UA(ECR.ORDER + 208, "The payment gateway unavailable or not supported"),
  PG_PREPAY_FAIL(ECR.ORDER + 209, "The payment gateway prepare payment failure"),
  PG_SIGN_TYPE_ERR(ECR.ORDER + 210, "The payment gateway signature type error"),
  PG_COMM_ERR(ECR.ORDER + 211, "The communication error occurring at payment gateway RMI"),
  PG_SIGN_ERR(ECR.ORDER + 212, "Payment gateway signature error"),
  /** 60400 - 60599 Payment gateway service related */
  INVALID_PG_TYPE(ECR.ORDER + 400, "Invalid payment gateway type"),
  INVALID_PG_CONF(ECR.ORDER + 401, "Invalid payment gateway config"),
  INVALID_PG_NAME(ECR.ORDER + 402, "Invalid payment gateway name"),
  /** 60800 - 60899 Delivery */
  //**********************************/
  //** 70000 - 79999 Security Errors */
  //**********************************/
  /** 70000 - 70099 System user service related */
  INVALID_UID(ECR.SECURITY, "Invalid system user ID"),
  INVALID_UAVATAR(ECR.SECURITY + 2, "Invalid system user avatar data"),
  INVALID_UNAME(ECR.SECURITY + 3, "Invalid system user name"),
  CU_CANNOT_REMOVE(ECR.SECURITY + 6, "Cannot delete current system user"),
  U_UA(ECR.SECURITY + 7, "The user status is unavailable"),
  U_NOTFOUND(ECR.SECURITY + 8, "User not found"),
  DUP_ULOGID(ECR.SECURITY + 10, "User login id duplicated, such as Username/Email/Mobile"),
  AA_CANNOT_REMOVE(ECR.SECURITY + 11, "Agency administrator cannot be delete"),
  /** 70100 - 70199 System role service related */
  INVALID_RNAME(ECR.SECURITY + 100, "Invalid role name"),
  DUP_RNAME(ECR.SECURITY + 101, "The role name has been used by other role"),
  /** 70200 - 70299 System captcha service related */
  CAPTCHA_EXPIRED(ECR.SECURITY + 200, "Captcha expired"),
  CAPTCHA_MISMATCH(ECR.SECURITY + 201, "Captcha mismatch"),
  /** Ending line */
  E_TITLE(ECR.SECURITY + 202, "Invalid title"),
  EOF(-1, "ONLY EOF");

  /**
   *
   */
  private final Integer code;
  /**
   *
   */
  private final String message;

  RSE(final int code, final String message) {
    this.code = code;
    this.message = message;
  }

  public String message() {
    return message;
  }

  public final Integer code() {
    return code;
  }
}
